<script setup>
import { ref,watch,reactive } from "vue";

const message = ref('')
const confirmData = ref('')
const user = reactive({
    name:"aa",
    age:20,
    phone:{
        title:"iphone",
        price:9999
    }
})

watch([message,confirmData],(newVal,oldVal)=>{
    //newVal和oldVal都是数组
    console.log(newVal,oldVal);
    if (newVal[0] === newVal[1]) {
        console.log('信息确认正常')
    }else{
        console.log('信息确认异常')
    }
})

watch(user,(newVal,oldVal)=>{
    console.log(newVal,oldVal);
})

// watch(()=>user.name,(newVal,oldVal)=>{
//     console.log(newVal,oldVal);
// })
</script>

<template>
    <div>
        <input type="text" v-model.lazy="message">
        <input type="text" v-model.lazy="confirmData">
        <input type="text" v-model.lazy="user.phone.title">
    </div>
</template>